package com.ccbft.msgcenter.mc.filter.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.ccbft.msgcenter.mc.filter.entity.Filter;
import com.ccbft.msgcenter.mc.filter.entity.Topics;
import com.ccbft.msgcenter.mc.filter.service.IFilterService;
import com.ccbft.msgcenter.mc.filter.service.ITopicsService;
import com.ccbft.msgcenter.mc.filter.vo.TopicVo;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author frank
 * @since 2019-07-25
 */
@RestController
@RequestMapping("/filter/topics")
public class TopicsController {
	
	@Autowired
	private ITopicsService topicsService;
	
	@RequestMapping(method=RequestMethod.POST, consumes = "application/json")
	public boolean add(@RequestBody TopicVo topic) {
		return topicsService.addTopic(topic);
	}
	
	@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
	public boolean deleteById(@PathVariable("id") Long id) {
		return topicsService.removeById(id);
	}
	
	@RequestMapping(method=RequestMethod.GET )
	public List<Topics> queryAll(){
		return topicsService.list();
	}
	
	@RequestMapping(value="/{id}", method=RequestMethod.GET)
	public Topics queryById(@PathVariable("id") Long id) {
		return topicsService.getById(id);
	}
	
	@RequestMapping(value="/{id}", method=RequestMethod.PUT)
	public boolean updateById(@PathVariable("id") Long id,@RequestBody Topics entity) {
		entity.setId(id);
		return topicsService.updateById(entity);
	}
}
